package com.ljz.dao.impl;

import com.ljz.dao.ItemDao;
import com.ljz.po.Item;
import org.mybatis.spring.support.SqlSessionDaoSupport;

import java.util.ArrayList;
import java.util.List;

public class ItemDaoImpl extends SqlSessionDaoSupport implements ItemDao {
    @Override
    public Item findItemById(Integer id) {
        return this.getSqlSession().selectOne("com.ljz.po" + ".ItemMapper.findItemById",id);
    }

    @Override
    public List findItem() {
        List list = new ArrayList();
        list = this.getSqlSession().selectList("com.ljz.po.ItemMapper.findItem");
        return list;
    }

    @Override
    public void delItemById(Integer id) {
        this.getSqlSession().delete("com.ljz.po.ItemMapper.delItemById",id);
    }

    @Override
    public void addItem(Item item) {
        this.getSqlSession().insert("com.ljz.po.ItemMapper.addItem",item);
    }

    @Override
    public void editItemById(Item item, Integer id) {
        item.setId(id);
        this.getSqlSession().update("com.ljz.po.ItemMapper.editItemById",item);
    }
}
